package com.sz.biz.app.web.security;

import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * Function: TODO: ADD FUNCTION <br>
 * Author: Charles. <br>
 * Date: 2017-05-05 11:01:00.
 */
@Component
public class UserLockedListener {

    @Autowired
    private EventBus eventBus;

    @Autowired
    private OnlineSessionManager onlineSessionManager;

    @PostConstruct
    public void registerSelf() {
        eventBus.register(this);
    }

    @Subscribe
    public void onEvent(String username) {
        if (username != null && username.length() > 0) {
            onlineSessionManager.kickoutOnlineSession(username);
        }
    }
}
